<%@ page import="org.xilin.Family" %>
<%@ page import="org.xilin.Student" %>
<g:setProvider library="jquery"/>

<g:if test="${flash.message}">
  <div class="message">${flash.message}</div>
</g:if>

<div class="bar">
  <span class="left">Students</span>
  <span class="btn right">
    <a class="create" href="#" title="Add Student" rel="${request.contextPath}/student/create">Add Student</a>
  </span>
</div>
<x:pager/>
<table id="studentTable" class="tablesorter">
  <thead>
    <tr>
      <th/>
      <th>${message(code: 'student.firstName.label', default: 'First Name')}</th>
      <th>${message(code: 'student.lastName.label', default: 'Last Name')}</th>
      <th>${message(code: 'student.chineseName', default: 'Chinese Name')}</th>
      <th>${message(code: 'student.gender', default: 'Gender')}</th>
      <th>${message(code: 'student.birthDay', default: 'Date of Birth')}</th>
      <th class="delete">Del</th>
      <th class="edit">Edit</th>
    </tr>
  </thead>
  <tbody>
  <g:each in="${familyInstance?.students}" status="i" var="studentInstance">
    <tr>
      <td></td>
      <td>${fieldValue(bean: studentInstance, field: "firstName")}</td>
      <td>${fieldValue(bean: studentInstance, field: "lastName")}</td>
      <td>${fieldValue(bean: studentInstance, field: "chineseName")}</td>
      <td>${fieldValue(bean: studentInstance, field: "gender")}</td>
      <td>${fieldValue(bean: studentInstance, field: "birthDay")}</td>
      <td class="delete"><g:remoteLink controller="student" action="delete" update="content" before="if(!confirm('Are you sure?')) return false;" id="${studentInstance.id}"><span class="ui-icon ui-icon-trash"/></g:remoteLink></td>
      <td class="edit"><a href="#" title="Edit Student" rel="${request.contextPath}/student/edit/${studentInstance.id}"><span class="ui-icon ui-icon-pencil"/></a></td>
    </tr>
  </g:each>
</tbody>
</table>

<script type="text/javascript">
  $(function(){
      setupAdminList({controller:'family', action:'studentList'});
  });
</script>

